import java.util.Random;

/**
 * If there are no bugs, it was created by Chen FengYao on 2018/4/3;
 * Otherwise, I don't know who created it either
 */

public class Question3 {
    public static void main(String[] args) {
        Random random = new Random();

        int[] arr = new int[20];

        for (int i = 0; i < arr.length; i++) {
            arr[i] = random.nextInt(20);
        }

        System.out.print("[");
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i]);
            if (i != arr.length - 1) {
                // 只要不是最后一个数组,就加上逗号
                System.out.print(",");
            }
        }
        System.out.println("]");//最后这个 还带换行

        int length = 0;
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] > 10) {
                length++;// 每发现一个符合条件的数,长度就加一
            }
        }

        int[] newArr = new int[length];

        int index = 0; // 现在要给新数组哪个位置进行赋值
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] > 10) {
                newArr[index] = arr[i];
                index++;
            }
        }

        for (int i = 0; i < newArr.length; i++) {
            System.out.print(newArr[i] + ",");
        }


    }
}
